#Cairo canvas. The following variables are available:
# * CNTX: A reference to the current cairo context object
# * W: Canvas width
# * H: Canvas height
# Have fun!

from math import pi
from random import randint

def draw( a_list, color ):
    CNTX.set_source_rgb(*color)
    for p in a_list:
        # sphere
        CNTX.arc( p[0], p[1], 7, 0, 2*pi)
        CNTX.fill()

# Blue background

blue_points = [ ( i, 0 ) for i in range(0, W, 20) ]

for i in range(0, H, 20):
    draw( [ (p[0], p[1] + i ) for p in blue_points], COLOR("NavyBlue") )


diag1 = [ ( i, i ) for i in range(0, W/2, 20) ]
for i in range(0,61,20):
    draw( [ (p[0], p[1] - i ) for p in diag1], COLOR("White") )
for i in range(0,21,20):
    draw( [ (p[0], p[1] + i ) for p in diag1], COLOR("Red") )
draw( [ (p[0], p[1] + 40 ) for p in diag1], COLOR("White") )

diag2 = [ ( i, i ) for i in range( max(range(0, W/2, 20))+20, W, 20) ]
draw( [ (p[0], p[1] - 60 ) for p in diag2], COLOR("White") )
for i in range(20,41,20):
    draw( [ (p[0], p[1] - i ) for p in diag2], COLOR("Red") )
for i in range(0,41,20):
    draw( [ (p[0], p[1] + i ) for p in diag2], COLOR("White") )
    
diag3 = [ ( i, max(range(0, W, 20) ) - i ) for i in range(0, W/2, 20) ]
for i in range(20, 61, 20):
    draw( [ (p[0], p[1] -i ) for p in diag3], COLOR("White") )
for i in range(0, 21, 20):
    draw( [ (p[0], p[1] +i ) for p in diag3], COLOR("Red") )
draw( [ (p[0], p[1] + 40 ) for p in diag3], COLOR("White") )
    
diag4 = [ ( i, max(range(0, W, 20) ) - i ) for i in range( max(range(0, W/2, 20)) + 20, W, 20) ]
draw( [ (p[0], p[1] - 60 ) for p in diag4], COLOR("White") )
for i in range(20, 41, 20):
    draw( [ (p[0], p[1] - i ) for p in diag4], COLOR("Red") )
for i in range(0, 41, 20):
    draw( [ (p[0], p[1] +i ) for p in diag4], COLOR("White") )

width_range = range(0, W, 20) 
draw( [ (p[0], width_range[len(width_range)/2-3] ) for p in blue_points], COLOR("White") )
draw( [ (p[0], width_range[len(width_range)/2+2] ) for p in blue_points], COLOR("White") )
draw( [ ( width_range[len(width_range)/2-3], p[0] ) for p in blue_points], COLOR("White") )
draw( [ ( width_range[len(width_range)/2+2], p[0] ) for p in blue_points], COLOR("White") )

for i in width_range[len(width_range)/2-2:len(width_range)/2+2]:
    draw( [ (p[0], i ) for p in blue_points], COLOR("Red") )

for i in width_range[len(width_range)/2-2:len(width_range)/2+2]:
    draw( [ (i, p[0]) for p in blue_points], COLOR("Red") )


